package org.zxy.base.util;


import org.zxy.org.domain.Employee;

import java.util.ArrayList;
import java.util.List;

/**
 * 创建一个工具类，用于导入表格时，对邮箱进行验证
 */
public class ImportExcelUtil {
    public static List<Employee> verifyEmail(List<Employee> list) {
        List<Employee> errorList = new ArrayList<>();
        //如果邮箱不正确，就跳出这个循环continue，并把错误的那行员工的数据放到错误表里errorList
        for (Employee employee : list) { //验证邮箱的正则表达式
            if (employee.getEmail().matches("^[a-zA-Z0-9_.-]+@[a-zA-Z0-9-]+(\\.[a-zA-Z0-9-]+)*\\.[a-zA-Z0-9]{2,6}$")) {
                continue;
            }
            errorList.add(employee);
        }
        return errorList;
    }
}
